<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.db.conn"%>
<%@ page import="com.db.Pagination"%>
<%@ page import="java.sql.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<jsp:include flush="true" page="${basePath}/admin/head.jsp"></jsp:include>
 <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">已支付订单</h3>
            </div>
            <div class="panel-body" style="min-height: 500px;">
           <table style="width:100%;"><tr><td align="center">
  <table class="layui-table" style="width:98%;margin-left:10px;" align="center">
                    <tbody>
                 <tr>
                <td align="center">
                                    <form action="<%=path %>/admin/orders/orders_Manage3.jsp" method="post">
                                        <strong> 房型:</strong><select name="se_rid" style='width:120px' id="ridid">
                                        <option value="">全部</option>
                                        <%
                                            conn cnrid=new conn();
                                            ResultSet rsrid=cnrid.query("select  rid,rname from roomtype ");
                                            while (rsrid.next()) {
                                        %>
                                        <option value="<%= rsrid.getString("rid") %>"><%=rsrid.getString("rname")%></option>
                                        <%} %>
                                    </select>
<strong> 订单编号:</strong><input name="txt_ono" type="text" id="txt_ono" style="width:120px;"  />

<strong> 姓名:</strong><input name="txt_mname" type="text" id="txt_mname" style="width:120px;"  />
<strong> 手机号码:</strong><input name="txt_tel" type="text" id="txt_tel" style="width:120px;"  />
<strong> 身份证号:</strong><input name="txt_cardno" type="text" id="txt_cardno" style="width:120px;"  />

                <input name="search" type="submit" border="0" class="btn btn-info"	value='查询' />
                </form>

   </td>
            </tr>
             <tr>
                <td align="center">
                      <%
//定义四个分页会用到的变量
int pageSize=15;
int pageNow=1;//默认显示第一页
int rowCount=0;//该值从数据库中查询
int pageCount=0;//该值是通过pageSize和rowCount
//接受用户希望显示的页数（pageNow）
String s_pageNow=request.getParameter("pageNum");
if(s_pageNow!=null){
//接收到了pageNow
pageNow=Integer.parseInt(s_pageNow);
}

String where="  oflag='已支付' ";
if(request.getParameter("txt_ono")!=null)
{
where+=" and ono like '%"+request.getParameter("txt_ono")+"%' ";
}


if(request.getParameter("se_rid")!=null  && request.getParameter("se_rid")!="")
{
where+=" and a.rid="+request.getParameter("se_rid");
}

if(request.getParameter("txt_mname")!=null)
{
where+=" and mname like '%"+request.getParameter("txt_mname")+"%' ";
}

if(request.getParameter("txt_tel")!=null)
{
where+=" and tel like '%"+request.getParameter("txt_tel")+"%' ";
}

if(request.getParameter("txt_cardno")!=null)
{
where+=" and cardno like '%"+request.getParameter("txt_cardno")+"%' ";
}


conn cn=new conn();


ResultSet rs=cn.query("select count(*) from orders a where "+where);
if(rs.next()){
rowCount=rs.getInt(1);
}

//计算pageCount
if(rowCount%pageSize==0){
pageCount=rowCount/pageSize;
}else{
pageCount=rowCount/pageSize+1;
}
//查询出需要显示的记录
 
rs=cn.query("select  a.*,b.rname from orders a  left join roomtype b on a.rid=b.rid " +
        " where "+where+" order by ono desc limit "+pageSize*(pageNow-1)+", "+pageSize);

%>

	<table cellspacing="0" border="0" style="width:100%;border-collapse:collapse;"  >
		<tr>
    <th >订单编号</th>
    <th >房型</th>
    <th >入住时间</th>
    <th >离开时间</th>


    <th >优惠后金额</th>

    <th >姓名</th>
    <th >手机号码</th>
    <th >身份证号</th>
    <th >提交时间</th>
    <th >订单状态</th>
			<th scope="col">操作</th>		</tr>
		<%
while(rs.next()){
%>
		<tr align="center" >
  			<td><%=rs.getString("ono") %></td>
 			<td><%=rs.getString("rname") %></td>
  			<td><%=rs.getString("sdate") %></td>
  			<td><%=rs.getString("edate") %></td>


  			<td><%=rs.getString("ymoney") %></td>

  			<td><%=rs.getString("mname") %></td>
  			<td><%=rs.getString("tel") %></td>
  			<td><%=rs.getString("cardno") %></td>
  			<td><%=rs.getString("otime") %></td>
  			<td><%=rs.getString("oflag") %></td>
			<td >
           <a href="<%=path %>/admin/orders/orders_Detail.jsp?id=<%=rs.getString("ono") %>">详细</a>&nbsp;
                <a href="<%=path %>/orders_Delete?id=<%=rs.getString("ono") %>&f=2">已完成</a>
           <a href="<%=path %>/orders_Delete?id=<%=rs.getString("ono") %>">删除</a>
		</tr>
<%} %>
  
					   </table>
             		 <table width=100%>
			 <tbody>
               <tr>
                <td align="center">
                       <%= Pagination.getPagination(pageNow,pageCount,rowCount,request.getRequestURI()) %>    
              </td>
              </tr>
                    </tbody>
                </table>
   </td></tr></table>
            

            </div>
        </div>




